#include <stdio.h>
int DayofYear (int year, int month, int day);

void main(){
		int y,m,d;
		scanf("%d %d %d", &y, &m, &d);
		printf("%d", DayofYear(y,m,d));
		
}

int DayofYear (int y, int m, int d){
	while (m>1){
	switch (m-1){
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
			case 1:d+=31;break;
			case 2:d+=(y%400==0 || y%4==0 && y%100!=0)?29:28;break;
			case 4:
			case 6:
			case 11:
			case 9:d+=30;break;	
		}
		m--;
	}
	return d;
}
